package com.atguigu.gulimall.mudan.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.gulimall.mudan.entity.FamilyEntity;
import com.atguigu.gulimall.mudan.service.FamilyService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 * 
 *
 * @author yashu
 * @email 2377311752@qq.com
 * @date 2021-06-17 20:31:18
 */
@RestController
@RequestMapping("mudan/family")
public class FamilyController {
    @Autowired
    private FamilyService familyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("mudan:family:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = familyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{peonyFamilyId}")
    //@RequiresPermissions("mudan:family:info")
    public R info(@PathVariable("peonyFamilyId") Integer peonyFamilyId){
		FamilyEntity family = familyService.getById(peonyFamilyId);

        return R.ok().put("family", family);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mudan:family:save")
    public R save(@RequestBody FamilyEntity family){
		familyService.save(family);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mudan:family:update")
    public R update(@RequestBody FamilyEntity family){
		familyService.updateById(family);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mudan:family:delete")
    public R delete(@RequestBody Integer[] peonyFamilyIds){
		familyService.removeByIds(Arrays.asList(peonyFamilyIds));

        return R.ok();
    }

}
